import Vue from 'vue'
import VueI18n from 'vue-i18n'
import App from './demos/App'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
import routeConfig from './routerConfig'
import Element from 'element-ui'
import './assets/css/common.less'
import locales from './assets/js/lang.js'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/style.css'
import cnlang from 'element-ui/lib/locale/lang/zh-CN'
import enlang from 'element-ui/lib/locale/lang/en'
import locale from 'element-ui/lib/locale'
import VueDND from 'awe-dnd'
import mixinOption from './mixinOption.js'
// import VueBlu from 'vue-blu'
// import 'vue-blu/dist/css/vue-blu.min.css'

//language
Vue.use(VueI18n)

Vue.use(VueDND)
Vue.mixin(mixinOption)
// Vue.use(VueBlu)

switch(language){
  case 'cn':
  locale.use(cnlang);
  Vue.config.lang = 'cn';
  break;
  case 'en':
  locale.use(enlang);
  Vue.config.lang = 'en'
  break;
}

// set locales
Object.keys(locales).forEach(function (lang) {
  Vue.locale(lang, locales[lang])
})

Vue.use(Element);

Vue.use(VueResource);
//加载路由中间件
Vue.use(VueRouter);
//定义路由
const router = new VueRouter({
  // mode: 'history',
  routes: routeConfig
})

// router.beforeEach((to, from, next) => {
//   console.log(to)
//   if(to.name==="Login"){
//     router.go(-1) 
//     next()
//   }else{
//     next();
//   }
// })

new Vue({
 router,
 el: "#app",
 render: h => h(App)
});

// Vue.filter("wrap", function(value) {
//   var wrapValue = value.replace(/a/g,"</p>")
//     return wrapValue;
// });